<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html><head>
        <link rel="stylesheet" type="text/css" href="apidocs.css"/>
        <title>API docs for &ldquo;sympy.functions.combinatorial.numbers.fibonacci&rdquo;</title>
        </head>
        <body><h1 class="class">Class s.f.c.n.fibonacci(<a href="sympy.core.function.Function.html">Function</a>):</h1><span id="part">Part of <a href="sympy.functions.combinatorial.numbers.html">sympy.functions.combinatorial.numbers</a></span><div class="toplevel"><div><p>Fibonacci numbers / Fibonacci polynomials</p>
<h1 class="heading">Usage</h1>
  <p>fibonacci(n) gives the nth Fibonacci number, F_n fibonacci(n, x) gives
  the nth Fibonacci polynomial in x, F_n(x)</p>
<h1 class="heading">Examples</h1>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span><span class="py-keyword">from</span> sympy <span class="py-keyword">import</span> *</pre>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>[fibonacci(x) <span class="py-keyword">for</span> x <span class="py-keyword">in</span> range(11)]
<span class="py-output">[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]</span>
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span>fibonacci(5, Symbol(<span class="py-string">'t'</span>))
<span class="py-output">1 + 3*t**2 + t**4</span></pre>
<h1 class="heading">Mathematical description</h1>
  <p>The Fibonacci numbers are the integer sequence defined by the initial 
  terms F_0 = 0, F_1 = 1 and the two-term recurrence relation F_n = F_{n-1}
  + F_{n-2}.</p>
  <p>The Fibonacci polynomials are defined by F_1(x) = 1, F_2(x) = x, and 
  F_n(x) = x*F_{n-1}(x) + F_{n-2}(x) for n &gt; 2. For all positive 
  integers n, F_n(1) = F_n.</p>
<h1 class="heading">References and further reading</h1>
  <p>* http://en.wikipedia.org/wiki/Fibonacci_number * 
  http://mathworld.wolfram.com/FibonacciNumber.html</p>
</div></div><table class="children"><tr class="function"><td>Function</td><td><a href="#sympy.functions.combinatorial.numbers.fibonacci._fib">_fib</a></td><td><span class="undocumented">Undocumented</span></td></tr><tr class="function"><td>Function</td><td><a href="#sympy.functions.combinatorial.numbers.fibonacci._fibpoly">_fibpoly</a></td><td><span class="undocumented">Undocumented</span></td></tr><tr class="function"><td>Function</td><td><a href="#sympy.functions.combinatorial.numbers.fibonacci.canonize">canonize</a></td><td><div><p>Returns a canonical form of cls applied to arguments args.</p>
</div></td></tr></table>
            <div class="function">
            <div class="functionHeader">def <a name="sympy.functions.combinatorial.numbers.fibonacci._fib">_fib(n, prev):</a></div>
            <div class="functionBody"><div class="undocumented">Undocumented</div></div>
            </div>
            <div class="function">
            <div class="functionHeader">def <a name="sympy.functions.combinatorial.numbers.fibonacci._fibpoly">_fibpoly(n, prev):</a></div>
            <div class="functionBody"><div class="undocumented">Undocumented</div></div>
            </div>
            <div class="function">
            <div class="functionHeader">def <a name="sympy.functions.combinatorial.numbers.fibonacci.canonize">canonize(cls, n, sym=None):</a></div>
            <div class="functionBody"><pre>Returns a canonical form of cls applied to arguments args.

The canonize() method is called when the class cls is about to be
instantiated and it should return either some simplified instance
(possible of some other class), or if the class cls should be
unmodified, return None.

Example of canonize() for the function "sign"
---------------------------------------------

@classmethod
def canonize(cls, arg):
    if arg is S.NaN:
        return S.NaN
    if arg is S.Zero: return S.One
    if arg.is_positive: return S.One
    if arg.is_negative: return S.NegativeOne
    if isinstance(arg, C.Mul):
        coeff, terms = arg.as_coeff_terms()
        if coeff is not S.One:
            return cls(coeff) * cls(C.Mul(*terms))</pre></div>
            </div></body>
        